package calendar;

import java.util.*;
import java.text.*;

public class Class_Appointment  {
private String appointmentDescription;  
private String appointmentName;  
private boolean appointmentHasOccured;  
private int appointmentYear;  
private int appointmentMonth;  
private int appointmentDay;  
private int appointmentTimeHour;  
private int appointmentTimeMinute;  
private int appointmentNumber;
private String appointmentType;
//Call for calendar time
Calendar systemCalendar = Calendar.getInstance();
Calendar appointmentCalendar=Calendar.getInstance();
//constructor for appointment
 Class_Appointment (String aName,String aDescription,int aYear,int aMonth,int aDay,int aTimeHour,int aTimeMinute,int aNumber,String aType){
    appointmentName=aName;
    appointmentDescription=aDescription;
    appointmentYear=aYear;
    appointmentMonth=aMonth;
    appointmentTimeHour=aTimeHour;
    appointmentTimeMinute=aTimeMinute;
    appointmentDay=aDay;
    appointmentNumber=aNumber;
    appointmentType=aType;
}
 Class_Appointment(){
     
 }

    //Queries
public int getAppointmentYear()  {  
return appointmentYear;

}
public int getAppointmentMonth()  { 
return appointmentMonth;  
}  
public int getAppointmentDay()  {  
return appointmentDay;  
}
public int getAppointmentTimeHour()  {  
return appointmentTimeHour;  
} 
public int getAppointmentTimeMinute()  {  
return appointmentTimeMinute;  }
public int getAppointmentNumber()  {  
return appointmentNumber;  
}
public String getAppointmentName()  {  
return appointmentName;  
} 
public String getDescription() {
    return appointmentDescription;
}
public String getAppointmentType(){
                  return appointmentType;
}
//commands
public void setAppointmentYear(int appointmentNewYear ){
 
 //if statments instead of try-catch
    if (appointmentNewYear<appointmentYear){
        System.out.println("Error appointment year is after your system year");
    }
    else{
    appointmentYear= appointmentNewYear;
    }
}
public void setAppointmentMonth(int appointmentNewMonth ){
        if ( appointmentNewMonth>12 || appointmentNewMonth<1) {
        
        System.out.println(" Month must be between 1 and 12");
    } else {
            appointmentMonth= appointmentNewMonth;
        }
    }

    public void setAppointmentDay(int appointmentNewDay ){
        appointmentDay= appointmentNewDay;
        switch (appointmentMonth){
        case 1:
            if (appointmentNewDay > 31 || appointmentNewDay < 1) {
                    System.out.println("Januwary days must be between 1 and 31");
                    } else {
                    appointmentDay=appointmentNewDay;
                };
            break;
        case 2:
            if (appointmentNewDay > 28 || appointmentNewDay < 1) {
                    System.out.println("February must be are between 1 and 28");
                    } else {
                    appointmentDay=appointmentNewDay;
                };
            break;
        
        case 3:
        if (appointmentNewDay > 31 || appointmentNewDay < 1) {
                System.out.println("March days must be between 1 and 31");
                } else {
                appointmentDay=appointmentNewDay;
            };
        break;
        case 4:
        if (appointmentNewDay > 30 || appointmentNewDay < 1) {
                System.out.println("April days must be between 1 and 3-");
                } else {
                appointmentDay=appointmentNewDay;
            };
        break;
        
        case 5:
        if (appointmentNewDay > 31 || appointmentNewDay < 1) {
                        System.out.println("May days must be between 1 and 31");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 6:
        if (appointmentNewDay > 30 || appointmentNewDay < 1) {
                        System.out.println("June days must be between 1 and 30");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 7:
        if (appointmentNewDay > 31 || appointmentNewDay < 1) {
                        System.out.println("July days must be between 1 and 31");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 8:
        if (appointmentNewDay > 30 || appointmentNewDay < 1) {
                        System.out.println("August days must be between 1 and 30");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 9:
        if (appointmentNewDay > 31 || appointmentNewDay < 1) {
                        System.out.println("September days must be between 1 and 31");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 10:
        if (appointmentNewDay > 30 || appointmentNewDay < 1) {
                        System.out.println("October days must be between 1 and 30");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 11:
        if (appointmentNewDay > 31 || appointmentNewDay < 1) {
                        System.out.println("Novemeber days must be between 1 and 31");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        case 12:
        if (appointmentNewDay > 30 || appointmentNewDay < 1) {
                        System.out.println("December days must be between 1 and 30");
                        } else {
                        appointmentDay=appointmentNewDay;
                    };
                break;
        };
}
public void setAppointmentTimeMinute (int appointmentNewMinute){
    if (appointmentNewMinute<0 || appointmentNewMinute >59){
        System.out.println("Minutes must be between 0 and 59");
    }else{
    appointmentTimeMinute=appointmentNewMinute;
    }
}

public void setAppointmentTimeHour (int appointmentNewHour){
    if (appointmentNewHour<0 || appointmentNewHour >59){
        System.out.println("Hours must be between 0 and 23");
    }else{
    appointmentTimeHour=appointmentNewHour;
    }
}
public void setDescription(String appointmentNewDescription){
    if(appointmentNewDescription.isEmpty()){
        System.out.println("Empty Description Field");
        }else{
   appointmentDescription= appointmentNewDescription;
        }
}
public void setAppointmentName (String appointmentNewName){
    if(appointmentNewName.isEmpty()){
        System.out.println("Empty Name Field");
        }else{
    appointmentName=appointmentNewName;
};
}
public long appointmentTimeinMillis(){
    appointmentCalendar.set(appointmentYear, appointmentMonth, appointmentDay, appointmentTimeHour, appointmentTimeMinute);
        long appCalInMIillis = appointmentCalendar.getTimeInMillis();
        return (appCalInMIillis);
                                                                                                                                                                                 }
public boolean appointmentHasOccured(){
   appointmentCalendar.set(appointmentYear, appointmentMonth, appointmentDay, appointmentTimeHour, appointmentTimeMinute);
   Long systemTime=systemCalendar.getTimeInMillis();
   Long appointmentTime=appointmentCalendar.getTimeInMillis();
    if(systemTime<appointmentTime){
    return true;
   }
   else{
    return false;
   }  
}
public void setAppointmentType(String appointmentNewType){
    if(appointmentNewType.isEmpty()){
        System.out.println("Empty Type Field");
        }else{
    appointmentType=appointmentNewType;
        }
}
public static void main(){
    System.out.println("hello");
}
//test
        public static void main(String[] args){
        int s;
        Scanner in = new Scanner(System.in);
            
            
            Class_Appointment Testplan = new Class_Appointment("App1","Test",2013,12,20,10,10,10,"first");
            
            Testplan.setAppointmentDay(s);
        System.out.print(Testplan.getAppointmentDay());
        }
    }

